package com.youlu.campus.admin.commission;


import com.youlu.campus.entity.commission.DistributorChannelActivity;
import com.youlu.campus.entity.commission.dto.DistributorChannelActivityDTO;
import com.youlu.campus.service.commission.DistributorChannelActivityService;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DistributorChannelActivityController {

    @Autowired
    private DistributorChannelActivityService distributorChannelActivityService;

    @PostMapping("/distributor/channel/activity/list")
    public QResult list (@RequestBody DistributorChannelActivityDTO dto){
        return QResult.success(distributorChannelActivityService.list(dto));
    }

    @PostMapping("/distributor/channel/activity/save")
    public QResult updateStatus(@RequestBody @Validated DistributorChannelActivity dto, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return QResult.fail(bindingResult.getFieldError().getDefaultMessage());
        }
        distributorChannelActivityService.save(dto);
        return QResult.success(null);
    }


}
